package com.chengfei.house.web.util;

import com.chengfei.house.common.model.User;
import com.chengfei.house.common.result.ResultMsg;
import org.apache.commons.lang3.StringUtils;

/**
 * @author chengfei cheng.fei@chinaott.onaliyun.com
 **/
public class UserHelper {
    public static ResultMsg valid(User account){
        if(StringUtils.isBlank(account.getEmail())){
            return ResultMsg.errorMsg("Email 必填");
        }
        if(StringUtils.isBlank(account.getName())){
            return ResultMsg.errorMsg("名字 必填");
        }
        if(StringUtils.isBlank(account.getConfirmPasswd()) ||
                StringUtils.isBlank(account.getPasswd()) ||
                !account.getConfirmPasswd().equals(account.getPasswd())){
            return ResultMsg.errorMsg("密码 有误");
        }
        if(account.getPasswd().length() < 6){
            return ResultMsg.errorMsg("密码必须大于6位");
        }
        return ResultMsg.successMsg("");
    }
}
